package order.servlet;

import com.alibaba.fastjson.JSON;
import order.entity.Orderbiao;
import order.service.OrderbiaoService;
import order.service.impl.OrderbiaoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/LoginIdServlet")
public class LoginIdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        String indexStr=request.getParameter("index");

        OrderbiaoService servise=new OrderbiaoServiceImpl();

        int index=Integer.parseInt(indexStr);

        List<Orderbiao> list= servise.getLike(index);

        PrintWriter out=response.getWriter();
        out.print(JSON.toJSONString(list));

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
